package com.lcq.demo.service;

import com.lcq.demo.entity.po.ScheduleTask;
import com.lcq.demo.entity.po.ScheduleTaskLog;
import com.lcq.demo.repository.ScheduleTaskLogRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

@Service
public class ScheduleTaskLogService {

    @Resource
    private ScheduleTaskLogRepository scheduleTaskLogRepository;


    public void logTaskExecution(ScheduleTask task, Integer executionStatus, Date startTime, Date endTime) {
        ScheduleTaskLog log = new ScheduleTaskLog();
        log.setTaskId(task.getId());
        log.setTaskName(task.getTaskName());
        log.setCallTarget(task.getCallTarget());
        log.setExecuteStatus(executionStatus);
        log.setStartedTime(startTime);
        log.setEndedTime(endTime);
        scheduleTaskLogRepository.save(log);
    }
}
